<%@page import="conexao.Connect"%>
<html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%
	
	boolean ok = false;	
	
	String Con_host = (String)request.getSession().getAttribute("Con_host");
	if (Con_host != null){
		String Con_database = (String) request.getSession().getAttribute("Con_database");
		String Con_usuario = (String) request.getSession().getAttribute("Con_usuario");
		String Con_senha = (String) request.getSession().getAttribute("Con_senha");
		
		Connect.updateConnection(Con_host,Con_database,Con_usuario,Con_senha);
		try{
			Connect.testConnection(request);
			ok = true;
		}catch(Exception ex){		
			//to-do
		}
	}	
	

	if (!ok){
		String host = config.getInitParameter("hostbd");
		String database = config.getInitParameter("databasebd");
		String usuariobd = config.getInitParameter("usuariobd");
		String senhabd = config.getInitParameter("senhabd");
	
		Connect.updateConnection(host,database,usuariobd,senhabd);
		try{
			Connect.testConnection(request);
		}catch(Exception ex){
			response.sendRedirect("index.jsp");
		}	
	}


	String empresa = (String) session.getAttribute("empresa");
	String modulo = (String) session.getAttribute("modulo");
	String esquema = (String) session.getAttribute("esquema");
	if (esquema == null) {
		esquema = "azul";
	}

	String esquemacss = (String) session.getAttribute("esquemacss");
	if (esquemacss == null) {
		esquemacss = "azul_S";
	}
	
	if (empresa == null) {
		empresa = " ";
	}

	if (modulo == null) {
		modulo = " ";
	}
		
%>
<head>
<link href="css/estilo.css" rel="stylesheet" type="text/css">
<link href="css/<%=esquemacss%>.css" rel="stylesheet" type="text/css" />
<link REL="SHORTCUT ICON" HREF="images/esquema/<%=esquema%>/favicon.ico" type="image/x-icon" />
<link REL="ICON" HREF="images/esquema/<%=esquema%>/favicon.ico" type="image/x-icon" />
</head>
<body>
<div align="center">
<table id="" width="100%" height="462px" border="0" cellpadding="8" cellspacing="8" >
  <tr height="90px">
   	<td valign="middle" align="center">
   	 <div id='div_logo' class="divlogo"></div>
   	</td>
  </tr>
   <tr>
    <td valign="top">
	  <table id="tbmsm" width="100%" class="tbmsm1">
	  <tr>
	     <td height="45px" width="40px">
	       <div id="msmico" class="imgicomsm"></div>
	     </td>
 	     <td>
         <div id="menssagem" class="stylemsm"></div>		     
	     </td>
	   </tr>	      
	  </table>
	 </td>
	</tr>
</table>        

</div>
</body>
</html>